package com.ef.web.action;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.write.BorderLineStyle;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;

import org.apache.struts2.ServletActionContext;
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.ef.constant.ConfirmMessage;
import com.ef.constant.ELeadsStatus;
import com.ef.constant.StatusType;
import com.ef.domain.Leads;
import com.ef.domain.LeadsEventHistory;
import com.ef.domain.MarketingPolicy;
import com.ef.domain.School;
import com.ef.domain.User;
import com.ef.service.LeadsDealHistoryService;
import com.ef.service.LeadsEventHistoryService;
import com.ef.service.LeadsService;
import com.ef.service.MarketingPolicyService;
import com.ef.service.SchoolService;
import com.ef.service.UserService;
import com.ef.util.CustomExample;
import com.ef.util.LeadsExample;
import com.ef.util.PaginationSupport;

public class LeadsAction extends BaseAction<Leads> {

	private static final long serialVersionUID = 1L;

	private final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
			.getLog(LeadsAction.class);
	protected LeadsEventHistoryService leadsEventHistoryService;
	protected LeadsDealHistoryService leadsDealHistoryService;

	protected LeadsService leadsService;
	protected SchoolService schoolService;
	protected MarketingPolicyService marketingPolicyService;
	protected UserService userService;
	protected Map<String, String> schoolList;
	protected Map<String, String> marketingPolicyList;
	protected List<MarketingPolicy> marketingPolicyArrList;
	protected Date selCreateStartTime;
	protected Date selCreateEndTime;
	protected Date selLastTouchStartTime;
	protected Date selLastTouchEndTime;
	protected Date selSetApptStartTime;
	protected Date selSetApptEndTime;
	protected Date selShowStartTime;
	protected Date selShowEndTime;
	protected Date selPayStartTime;
	protected Date selPayEndTime;
	protected Date selAssignTmStartTime;
	protected Date selAssignTmEndTime;
	protected Date selAssignCcStartTime;
	protected Date selAssignCcEndTime;
	protected Date selAssignCrStartTime;
	protected Date selAssignCrEndTime;
	protected Date selInitVisitStartTime;
	protected Date selInitVisitEndTime;
	protected Date selOriginalClassTimeStartTime;
	protected Date selOriginalClassTimeEndTime;
	protected Integer selTmCall;

	public Integer getSelTmCall() {
		return selTmCall;
	}

	public void setSelTmCall(Integer selTmCall) {
		this.selTmCall = selTmCall;
	}

	protected List<LeadsEventHistory> calls;

	@SuppressWarnings("serial")
	public String list() {
		fetchListData();
		CustomExample<Leads> example = new LeadsExample(this.getModel(),
				Leads.class) {
			public void appendCondition(Criteria criteria) {
				super.appendCondition(criteria);
				User user = getSessionUser();
				// 如果是市场人员
				// 查找是同一team的id
				if (user.getRole().getName().equalsIgnoreCase("MK")) {
					if (user.getTeam() != null) {
						criteria.createCriteria("team").add(
								Restrictions.eq("id", user.getTeam().getId()));
					}
				}
				if (selTmCall != null) {
					criteria.add(Restrictions.eq("tmCall", selTmCall));
				}
				criteria.addOrder(Order.desc("updateTime"));
			}
		};
		example.addBetweenDateProperty("createTime", selCreateStartTime,
				selCreateEndTime);
		example.addBetweenDateProperty("setApptTime", selSetApptStartTime,
				selSetApptEndTime);
		example.addBetweenDateProperty("showTime", selShowStartTime,
				selShowEndTime);
		example.addBetweenDateProperty("lastEventTime", selLastTouchStartTime,
				selLastTouchEndTime);
		example.addBetweenDateProperty("payTime", selPayStartTime,
				selPayEndTime);
		example.addBetweenDateProperty("initVisitTime", selInitVisitStartTime,
				selInitVisitEndTime);
		example.addBetweenDateProperty("originalClassTime",
				selOriginalClassTimeStartTime, selOriginalClassTimeEndTime);
		this.listResult = leadsService.findByExample(example, this
				.getStartIndex(), this.getPageSize());

		return LIST;
	}

	public Boolean isOwner(String id) {
		if (id == null) {
			return true;
		}
		Leads leads = leadsService.findById(Long.valueOf(id.trim()));
		if (leads != null
				&& leads.getCreateUser() != null
				&& getSessionUser().getId().equals(
						leads.getCreateUser().getId())) {
			return true;
		}
		return false;
	}

	public String edit() {
		fetchListData();
		if (this.getModel().getId() != null) {
			calls = leadsEventHistoryService.findByLeads(this.getModel());
		}
		return EDIT;
	}

	public Boolean canChangeStatus() {
		if (this.getModel().getLeadsStatus() != null) {
			if (this.getModel().getLeadsStatus().equals(ELeadsStatus.ShowUp)
					|| this.getModel().getLeadsStatus()
							.equals(ELeadsStatus.Pay)) {
				return false;
			} else {
				return true;
			}
		}
		return true;
	}

	public String view() {
		fetchListData();
		if (this.getModel().getId() != null) {
			calls = leadsEventHistoryService.findByLeads(this.getModel());
		}
		return VIEW;
	}

	public List<LeadsEventHistory> getCalls() {
		return calls;
	}

	public void setCalls(List<LeadsEventHistory> calls) {
		this.calls = calls;
	}

	public LeadsEventHistoryService getLeadsEventHistoryService() {
		return leadsEventHistoryService;
	}

	public void setLeadsEventHistoryService(
			LeadsEventHistoryService leadsEventHistoryService) {
		this.leadsEventHistoryService = leadsEventHistoryService;
	}

	public String clean() {
		fetchListData();
		this.listResult = new PaginationSupport<Leads>(new ArrayList<Leads>(),
				0);
		return LIST;
	}

	public String save() {
		Leads leads = saveLeads();
		fetchListData();
		if (leads == null) {
			calls = leadsEventHistoryService.findByLeads(leads);
			return CALL;
		}
		return EDIT;
	}

	protected Leads saveLeads() {
		Leads leads = this.getModel();
		if (leads.getId() == null) {
			List<Leads> lll = this.leadsService.findDuplicateLeads(leads);
			if (lll != null && lll.size() > 0) {
				StringBuffer info = new StringBuffer();
				for (Leads aa : lll) {
					info.append(aa.getName()).append(" has the same tel!");
				}
				resultError(info.toString(), "list");
				return null;
			}
			leads.setCreateUser(getSessionUser());
			leads.setCreateTime(new Date());
			if (getSessionUser().getRole().getName().toUpperCase().equals("CC")) {
				leads.setCc(getSessionUser());
				if (getSessionUser().getSchool() != null) {
					leads.setSchool(getSessionUser().getSchool());
				}
			} else if (getSessionUser().getRole().getName().toUpperCase()
					.equals("TM")) {
				leads.setTm(getSessionUser());
			} else if (getSessionUser().getSchool() != null) {
				leads.setSchool(getSessionUser().getSchool());
			}
			if (getSessionUser().getTeam() != null) {
				leads.setTeam(getSessionUser().getTeam());
			}
			;
		}
		;
		if (leads.getLeadsStatus() == null) {
			leads.setLeadsStatus(ELeadsStatus.New);
		}
		if (leads.getAdChannel() != null
				&& leads.getAdChannel().getId() == null) {
			leads.setAdChannel(null);
		}
		if (leads.getMarketingPlan() != null
				&& leads.getMarketingPlan().getId() == null) {
			leads.setMarketingPlan(null);
		}
		if (leads.getPte() != null && leads.getPte().getId() == null) {
			leads.setPte(null);
		}
		if (leads.getPteLeader() != null
				&& leads.getPteLeader().getId() == null) {
			leads.setPteLeader(null);
		}
		if (leads.getMarketingPolicy() != null
				&& leads.getMarketingPolicy().getId() == null) {
			leads.setMarketingPolicy(null);
		}
		if (leads.getSchool() != null && leads.getSchool().getId() == null) {
			leads.setSchool(null);
		}
		if (leads.getTm() != null && leads.getTm().getId() == null) {
			leads.setTm(null);
		}
		leads.setUpdateTime(new Date());
		leads.setUpdateUser(getSessionUser());
		leadsService.saveOrUpdate(leads);
		this.setResult(ConfirmMessage.Leads);
		return leads;
	}

	public String delete() {
		String ids = getRequest().getParameter("ids");
		String[] id = ids.split(",");
		for (String i : id) {
			// 只有本人的New Leads 可以删除
			Leads leads = leadsService.findById(Long.valueOf(i.trim()));
			if (leads.getLeadsStatus().equals(ELeadsStatus.New)) {
				if (leads.getCreateUser().getId().equals(
						getSessionUser().getId())) {
					leadsService.delete(leads);
				}
			}
		}
		return DELETE;
	}

	public String Import() {
		fetchListData();
		return "import";
	}

	@SuppressWarnings("serial")
	public String export() {
		CustomExample<Leads> example = new LeadsExample(this.getModel(),
				Leads.class) {
			public void appendCondition(Criteria criteria) {
				super.appendCondition(criteria);
				User user = getSessionUser();
				// 如果是市场人员
				// 查找是同一team的id
				if (user.getRole().getName().equalsIgnoreCase("MK")) {
					if (user.getTeam() != null) {
						criteria.createCriteria("team").add(
								Restrictions.eq("id", user.getTeam().getId()));
					}
				}
				if (selTmCall != null) {
					criteria.add(Restrictions.eq("tmCall", selTmCall));
				}
			}
		};
		example.addBetweenDateProperty("createTime", selCreateStartTime,
				selCreateEndTime);
		example.addBetweenDateProperty("setApptTime", selSetApptStartTime,
				selSetApptEndTime);
		example.addBetweenDateProperty("showTime", selShowStartTime,
				selShowEndTime);
		example.addBetweenDateProperty("lastEventTime", selLastTouchStartTime,
				selLastTouchEndTime);
		example.addBetweenDateProperty("payTime", selPayStartTime,
				selPayEndTime);
		example.addBetweenDateProperty("initVisitTime", selInitVisitStartTime,
				selInitVisitEndTime);
		example.addBetweenDateProperty("originalClassTime",
				selOriginalClassTimeStartTime, selOriginalClassTimeEndTime);
		PaginationSupport<Leads> result = leadsService.findByExample(example,
				this.getStartIndex(), 60000);

		HttpServletRequest request = getRequest();
		HttpServletResponse response = getResponse();

		response.setContentType("application/ms-excel;charset=UTF-8");
		response.setHeader("Content-Disposition",
				"attachment;filename=exportleads.xls");

		File tempPath = new File(ServletActionContext.getServletContext()
				.getRealPath("/temp"));
		if (!tempPath.exists()) {
			tempPath.mkdirs();
		}
		WritableWorkbook workBook;

		File exportFile = new File(ServletActionContext.getServletContext()
				.getRealPath("/temp/exportleads.xls"));
		try {
			// TODO styles
			WritableFont font = new WritableFont(WritableFont.TIMES, 12,
					WritableFont.BOLD);
			WritableCellFormat headStyle = new WritableCellFormat(font);
			headStyle.setAlignment(Alignment.CENTRE);
			WritableCellFormat titleStyle = new WritableCellFormat(font);
			titleStyle.setAlignment(Alignment.CENTRE);
			titleStyle.setWrap(false);
			titleStyle.setBorder(Border.ALL, BorderLineStyle.THIN);
			WritableFont font_content = new WritableFont(WritableFont.TIMES, 10);
			WritableCellFormat contentStyle = new WritableCellFormat(
					font_content);
			contentStyle.setAlignment(Alignment.CENTRE);
			contentStyle.setBorder(Border.ALL, BorderLineStyle.THIN);
			contentStyle.setWrap(false);
			workBook = Workbook.createWorkbook(exportFile);
			workBook.setProtected(false);

			// create sheets
			WritableSheet activeSheet = workBook.createSheet("Export Leads", 0);

			activeSheet.addCell(new Label(0, 0, "Name ", titleStyle));
			activeSheet.addCell(new Label(1, 0, "Tel   ", titleStyle));
			activeSheet.addCell(new Label(2, 0, "Tel2   ", titleStyle));
			activeSheet
					.addCell(new Label(3, 0, "Marketing Policy ", titleStyle));
			activeSheet.addCell(new Label(4, 0, "Marketing ", titleStyle));
			activeSheet.addCell(new Label(5, 0, "Comment  ", titleStyle));
			activeSheet.addCell(new Label(6, 0, "TM   ", titleStyle));
			activeSheet.addCell(new Label(7, 0, " PTE ", titleStyle));
			activeSheet.addCell(new Label(8, 0, " PNO ", titleStyle));
			activeSheet
					.addCell(new Label(9, 0, "Init visit time ", titleStyle));
			activeSheet.addCell(new Label(10, 0, "Call Status ", titleStyle));
			activeSheet.addCell(new Label(11, 0, "Team Leader ", titleStyle));
			activeSheet.addCell(new Label(12, 0, "TNO ", titleStyle));
			activeSheet.addCell(new Label(13, 0, "AREA ", titleStyle));
			activeSheet.addCell(new Label(14, 0, "CC ", titleStyle));
			activeSheet.addCell(new Label(15, 0, "Creator ", titleStyle));
			activeSheet.addCell(new Label(16, 0, "Last Comments ", titleStyle));
			activeSheet.addCell(new Label(17, 0, "TmCallCount ", titleStyle));
			activeSheet.addCell(new Label(18, 0, "LeadSource ", titleStyle));
			activeSheet.addCell(new Label(19, 0, "AdChannel ", titleStyle));
			int size = result.getItems().size();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
			for (int i = 0; i < size; i++) {
				Leads leads = result.getItems().get(i);
				activeSheet.addCell(new Label(0, i + 1, leads.getName(),
						contentStyle));
				if (leads.getLeadsStatus() != null
						&& (leads.getLeadsStatus().equals(
								ELeadsStatus.InvalidPhoneNumber) || leads
								.getLeadsStatus().equals(
										ELeadsStatus.Notinterest))) {
					activeSheet.addCell(new Label(1, i + 1, leads
							.getMobileTelephone() == null ? "" : leads
							.getMobileTelephone(), contentStyle));
					activeSheet.addCell(new Label(2, i + 1,
							leads.getTelephone() == null ? "" : leads
									.getTelephone(), contentStyle));
				} else {
					activeSheet.addCell(new Label(1, i + 1, "", contentStyle));
					activeSheet.addCell(new Label(2, i + 1, "", contentStyle));
				}
				if (leads.getMarketingPolicy() != null)
					activeSheet.addCell(new Label(3, i + 1, leads
							.getMarketingPolicy().getName(), contentStyle));
				else
					activeSheet.addCell(new Label(3, i + 1, "", contentStyle));
				if (leads.getMarketingPlan() != null)
					activeSheet.addCell(new Label(4, i + 1, leads
							.getMarketingPlan().getName(), contentStyle));
				else
					activeSheet.addCell(new Label(4, i + 1, "", contentStyle));
				activeSheet.addCell(new Label(5, i + 1, leads.getComments(),
						contentStyle));
				if (leads.getTm() != null)
					activeSheet.addCell(new Label(6, i + 1, leads.getTm()
							.getName(), contentStyle));
				else
					activeSheet.addCell(new Label(6, i + 1, "", contentStyle));
				if (leads.getPte() != null) {
					activeSheet.addCell(new Label(7, i + 1, leads.getPte()
							.getName(), contentStyle));
					activeSheet.addCell(new Label(8, i + 1, leads.getPte()
							.getWorknumber(), contentStyle));
				} else {
					activeSheet.addCell(new Label(7, i + 1, "", contentStyle));
					activeSheet.addCell(new Label(8, i + 1, "", contentStyle));
				}
				if (leads.getInitVisitTime() != null)
					activeSheet.addCell(new Label(9, i + 1, sdf.format(leads
							.getInitVisitTime()), contentStyle));
				else
					activeSheet.addCell(new Label(9, i + 1, "", contentStyle));
				activeSheet.addCell(new Label(10, i + 1, (leads
						.getLeadsStatus() == null ? "" : leads.getLeadsStatus()
						.toString()), contentStyle));
				if (leads.getPteLeader() != null) {
					activeSheet.addCell(new Label(11, i + 1, (leads
							.getPteLeader() == null ? "" : leads.getPteLeader()
							.getName()), contentStyle));
					activeSheet.addCell(new Label(12, i + 1, (leads
							.getPteLeader() == null ? "" : leads.getPteLeader()
							.getWorknumber()), contentStyle));
				} else {
					activeSheet.addCell(new Label(11, i + 1, "", contentStyle));
					activeSheet.addCell(new Label(12, i + 1, "", contentStyle));
				}

				activeSheet.addCell(new Label(13, i + 1,
						leads.getCity() == null ? "" : leads.getCity(),
						contentStyle));

				activeSheet.addCell(new Label(14, i + 1,
						leads.getCc() == null ? "" : leads.getCc().getName(),
						contentStyle));

				activeSheet.addCell(new Label(15, i + 1,
						leads.getCreateUser() == null ? "" : leads
								.getCreateUser().getName(), contentStyle));
				activeSheet.addCell(new Label(16, i + 1, leads
						.getLastEventCommons(), contentStyle));
				activeSheet.addCell(new Label(17, i + 1, String.valueOf(leads
						.getTmCall()), contentStyle));

				activeSheet.addCell(new Label(18, i + 1,
						leads.getLeadsSource() == null ? "" : leads
								.getLeadsSource().toString(), contentStyle));
				activeSheet.addCell(new Label(19, i + 1,
						leads.getAdChannel() == null ? "" : leads
								.getAdChannel().getName(), contentStyle));
			}

			workBook.write();
			workBook.close();

		} catch (IOException e) {
			e.printStackTrace();
		} catch (WriteException e) {
			e.printStackTrace();
		}
		RequestDispatcher dispatcher = request
				.getRequestDispatcher("../../temp/exportleads.xls");
		try {
			dispatcher.forward(request, response);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return NONE;
	}

	protected void fetchListData() {
		Map<String, String> map2 = new LinkedHashMap<String, String>();
		marketingPolicyArrList = marketingPolicyService.findAll();
		for (MarketingPolicy m : marketingPolicyArrList) {
			map2.put(m.getId().toString(), m.getName());
		}
		marketingPolicyList = map2;
		Map<String, String> schoolMap = new LinkedHashMap<String, String>();

		List<School> schools = schoolService.findAll();

		for (School s : schools) {
			if (s.getStatus() == StatusType.VALID)
				schoolMap.put(s.getId().toString(), s.getName());
		}
		schoolList = schoolMap;

	}

	public List<MarketingPolicy> getMarketingPolicyArrList() {
		return marketingPolicyArrList;
	}

	public void setMarketingPolicyArrList(
			List<MarketingPolicy> marketingPolicyArrList) {
		this.marketingPolicyArrList = marketingPolicyArrList;
	}

	public LeadsService getLeadsService() {
		return leadsService;
	}

	public void setLeadsService(LeadsService leadsService) {
		this.leadsService = leadsService;
	}

	public SchoolService getSchoolService() {
		return schoolService;
	}

	public void setSchoolService(SchoolService schoolService) {
		this.schoolService = schoolService;
	}

	public Map<String, String> getSchoolList() {
		return schoolList;
	}

	public void setSchoolList(Map<String, String> schoolList) {
		this.schoolList = schoolList;
	}

	public MarketingPolicyService getMarketingPolicyService() {
		return marketingPolicyService;
	}

	public void setMarketingPolicyService(
			MarketingPolicyService marketingPolicyService) {
		this.marketingPolicyService = marketingPolicyService;
	}

	public Map<String, String> getMarketingPolicyList() {
		return marketingPolicyList;
	}

	public void setMarketingPolicyList(Map<String, String> marketingPolicyList) {
		this.marketingPolicyList = marketingPolicyList;
	}

	// TODO 中文过滤
	public String autoCompleteAjax() {
		HttpServletResponse response = ServletActionContext.getResponse();
		HttpServletRequest request = ServletActionContext.getRequest();
		response.setHeader("Cache-Control", "no-cache");
		response.setContentType("text/plain;charset=GBK ");
		PrintWriter out = null;
		try {
			String q = request.getParameter("q");
			String limit = request.getParameter("limit");
			School school = this.getSessionUser().getSchool();
			List<Leads> list = null;
			if (school != null) {
				list = leadsService.findByAnythingInSchool(q, school.getId(),
						Integer.valueOf(limit));
			} else {
				list = leadsService.findByAnything(q, Integer.valueOf(limit));
			}
			// {id:id,name:name}
			String responseStr = "";
			// System.out.println(q);
			out = response.getWriter();
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			String depTime = "";
			String dep = "";
			for (Leads key : list) {
				if (key.getDepositTime() != null) {
					depTime = df.format(key.getDepositTime());
				} else {
					depTime = "";
				}
				if (key.getDeposit() != null) {
					dep = key.getDeposit().toString();
				} else {
					dep = "";
				}
				responseStr = ("{id:") + (key.getId()) + (",name:\"")
						+ (key.getName()) + ("\",tel:\"")
						+ (key.getMobileTelephone()) + ("\",card:\"")
						+ (key.getEliteCard()) + ("\",deposit:\"") + (dep)
						+ ("\",depositTime:\"") + depTime + ("\",status:\"")
						+ (key.getLeadsStatus()) + ("\"}");
				// System.out.println(responseStr);
				out.println(responseStr);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (out != null) {
				try {
					out.close();
				} catch (Exception e) {

				}
			}
		}
		return null;
	}

	// TODO 中文过滤
	public String autoCompleteAjaxByCC() {
		HttpServletResponse response = ServletActionContext.getResponse();
		HttpServletRequest request = ServletActionContext.getRequest();
		response.setHeader("Cache-Control", "no-cache");
		response.setContentType("text/plain;charset=GBK ");
		PrintWriter out = null;
		try {
			String q = request.getParameter("q");
			String limit = request.getParameter("limit");
			User user = this.getSessionUser();
			List<Leads> list = null;
			if (user != null && user.getRole() != null
					&& user.getRole().getName().trim().equalsIgnoreCase("CC")) {
				list = leadsService.findByAnythingByCC(q, user.getId(), Integer
						.valueOf(limit));
			} else {
				list = leadsService.findByAnything(q, Integer.valueOf(limit));
			}
			// {id:id,name:name}
			String responseStr = "";
			// System.out.println(q);
			out = response.getWriter();
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			String depTime = "";
			String dep = "";
			for (Leads key : list) {
				if (key.getDepositTime() != null) {
					depTime = df.format(key.getDepositTime());
				} else {
					depTime = "";
				}
				if (key.getDeposit() != null) {
					dep = key.getDeposit().toString();
				} else {
					dep = "";
				}
				responseStr = ("{id:") + (key.getId()) + (",name:\"")
						+ (key.getName()) + ("\",tel:\"")
						+ (key.getMobileTelephone()) + ("\",card:\"")
						+ (key.getEliteCard()) + ("\",deposit:\"") + (dep)
						+ ("\",depositTime:\"") + depTime + ("\",status:\"")
						+ (key.getLeadsStatus()) + ("\"}");
				// System.out.println(responseStr);
				out.println(responseStr);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (out != null) {
				try {
					out.close();
				} catch (Exception e) {

				}
			}
		}
		return null;
	}

	public Date getSelCreateStartTime() {
		return selCreateStartTime;
	}

	public void setSelCreateStartTime(Date selCreateStartTime) {
		this.selCreateStartTime = selCreateStartTime;
	}

	public Date getSelCreateEndTime() {
		return selCreateEndTime;
	}

	public void setSelCreateEndTime(Date selCreateEndTime) {
		this.selCreateEndTime = selCreateEndTime;
	}

	public Date getSelLastTouchStartTime() {
		return selLastTouchStartTime;
	}

	public void setSelLastTouchStartTime(Date selLastTouchStartTime) {
		this.selLastTouchStartTime = selLastTouchStartTime;
	}

	public Date getSelLastTouchEndTime() {
		return selLastTouchEndTime;
	}

	public void setSelLastTouchEndTime(Date selLastTouchEndTime) {
		this.selLastTouchEndTime = selLastTouchEndTime;
	}

	public Date getSelSetApptStartTime() {
		return selSetApptStartTime;
	}

	public void setSelSetApptStartTime(Date selSetApptStartTime) {
		this.selSetApptStartTime = selSetApptStartTime;
	}

	public Date getSelSetApptEndTime() {
		return selSetApptEndTime;
	}

	public void setSelSetApptEndTime(Date selSetApptEndTime) {
		this.selSetApptEndTime = selSetApptEndTime;
	}

	public Date getSelShowStartTime() {
		return selShowStartTime;
	}

	public void setSelShowStartTime(Date selShowStartTime) {
		this.selShowStartTime = selShowStartTime;
	}

	public Date getSelShowEndTime() {
		return selShowEndTime;
	}

	public void setSelShowEndTime(Date selShowEndTime) {
		this.selShowEndTime = selShowEndTime;
	}

	public Date getSelPayStartTime() {
		return selPayStartTime;
	}

	public void setSelPayStartTime(Date selPayStartTime) {
		this.selPayStartTime = selPayStartTime;
	}

	public Date getSelPayEndTime() {
		return selPayEndTime;
	}

	public void setSelPayEndTime(Date selPayEndTime) {
		this.selPayEndTime = selPayEndTime;
	}

	public Date getSelAssignTmStartTime() {
		return selAssignTmStartTime;
	}

	public void setSelAssignTmStartTime(Date selAssignTmStartTime) {
		this.selAssignTmStartTime = selAssignTmStartTime;
	}

	public Date getSelAssignTmEndTime() {
		return selAssignTmEndTime;
	}

	public void setSelAssignTmEndTime(Date selAssignTmEndTime) {
		this.selAssignTmEndTime = selAssignTmEndTime;
	}

	public Date getSelAssignCcStartTime() {
		return selAssignCcStartTime;
	}

	public void setSelAssignCcStartTime(Date selAssignCcStartTime) {
		this.selAssignCcStartTime = selAssignCcStartTime;
	}

	public Date getSelAssignCcEndTime() {
		return selAssignCcEndTime;
	}

	public void setSelAssignCcEndTime(Date selAssignCcEndTime) {
		this.selAssignCcEndTime = selAssignCcEndTime;
	}

	public Date getSelAssignCrStartTime() {
		return selAssignCrStartTime;
	}

	public void setSelAssignCrStartTime(Date selAssignCrStartTime) {
		this.selAssignCrStartTime = selAssignCrStartTime;
	}

	public Date getSelAssignCrEndTime() {
		return selAssignCrEndTime;
	}

	public void setSelAssignCrEndTime(Date selAssignCrEndTime) {
		this.selAssignCrEndTime = selAssignCrEndTime;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public LeadsDealHistoryService getLeadsDealHistoryService() {
		return leadsDealHistoryService;
	}

	public void setLeadsDealHistoryService(
			LeadsDealHistoryService leadsDealHistoryService) {
		this.leadsDealHistoryService = leadsDealHistoryService;
	}

	public Date getSelInitVisitStartTime() {
		return selInitVisitStartTime;
	}

	public void setSelInitVisitStartTime(Date selInitVisitStartTime) {
		this.selInitVisitStartTime = selInitVisitStartTime;
	}

	public Date getSelInitVisitEndTime() {
		return selInitVisitEndTime;
	}

	public void setSelInitVisitEndTime(Date selInitVisitEndTime) {
		this.selInitVisitEndTime = selInitVisitEndTime;
	}

	public Date getSelOriginalClassTimeStartTime() {
		return selOriginalClassTimeStartTime;
	}

	public void setSelOriginalClassTimeStartTime(
			Date selOriginalClassTimeStartTime) {
		this.selOriginalClassTimeStartTime = selOriginalClassTimeStartTime;
	}

	public Date getSelOriginalClassTimeEndTime() {
		return selOriginalClassTimeEndTime;
	}

	public void setSelOriginalClassTimeEndTime(Date selOriginalClassTimeEndTime) {
		this.selOriginalClassTimeEndTime = selOriginalClassTimeEndTime;
	}

}
